<template>
    <yk-space dir="vertical" style="width: 100%; margin-bottom: 8px;" >
         <TopTitle name="摄影图库" :is-search="true" style="width: 100%; margin-bottom: 8px;"  @search="search" />
         <Subset :classify="1" @nowSubset="nowSubset"  v-show="query" />
         <Gallery style="width: 100%;" :subsetId="nowSubsetId" :state="nowState" :searchTerm="searchTerm"/>
    </yk-space>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import TopTitle from '../components/bar/TopTitle.vue';
import Subset from '../components/subset/subset.vue';
import Gallery from '../components/gallerys/gallery.vue';
const nowState = ref<number>(-1) //当前是否发布状态
const nowSubsetId = ref<number>(-1) //当前分组id
const nowSubset = (e:{id: number, type:string}) => {
    if(e.type === 'all'){
        nowState.value = -1
        nowSubsetId.value = -1
    } else if(e.type === 'subset' || e.type==='exclude'){
        nowState.value = -1
        nowSubsetId.value = e.id
    }
} 

//搜索事件
const searchTerm = ref<string>('')
const query=ref<boolean>(true)
const search = (val: string) => {
    searchTerm.value = val
    if(val){
        query.value = false
    }else{
        query.value = true
    }
}
</script>

<style scoped lang="less">  

</style>